import Action from '../core/Action';

export default class extends Action {
    constructor(duration,  option) {
        super(duration);
    }

    update(node, frame) {
        if (this.duration === 0 && !this.running) {
            return;
        }

        if (!node.locked) {
            let targetAngle = (this.duration - frame) / this.duration * 360;
            if (frame === 1) {
                targetAngle = 360;
            }
            node.angle = targetAngle;
            node.make();
            this.beforeUpdate && this.beforeUpdate(node, frame);
            node.canvas.paint();
        }
    }
}
